<template>
  <div>
    <el-form
      ref="translateEnvConfig"
      :model="form"
      label-width="150px"
    >
      <el-form-item
        label="翻译平台"
        prop="type"
      >
        <el-select
          v-model="form.type"
          placeholder="请选择翻译平台"
          style="width: 35%"
        >
          <el-option
            label="腾讯翻译"
            value="TENCENT"
          ></el-option>
          <el-option
            label="百度翻译"
            value="BAIDU"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item
        v-if="form.type === 'TENCENT'"
        :rules="[{ required: true, message: '请输入secretId', trigger: 'blur' }]"
        label="secretId"
        prop="secretId"
      >
        <el-input
          v-model="form.secretId"
          placeholder="请输入secretId"
          show-password
        ></el-input>
      </el-form-item>

      <el-form-item
        :rules="[{ required: true, message: '请输入secretKey', trigger: 'blur' }]"
        label="secretKey"
        prop="secretKey"
      >
        <el-input
          v-model="form.secretKey"
          placeholder="请输入secretKey"
          show-password
        ></el-input>
      </el-form-item>

      <el-form-item
        v-if="form.type === 'BAIDU'"
        :rules="[{ required: true, message: '请输入appId', trigger: 'blur' }]"
        label="appId"
        prop="appId"
      >
        <el-input
          v-model="form.appId"
          placeholder="请输入appId"
        ></el-input>
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          @click="handleSubmit"
        >
          {{ $t("common.save") }}
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import ConfigMixin from "./ConfigMixin";

export default {
  name: "TranslateConfig",
  mixins: [ConfigMixin],
  data() {
    return {
      form: {
        type: "",
        secretId: "",
        secretKey: "",
        appId: ""
      }
    };
  },
  async created() {
    this.activeName = "translateEnvConfig";
    await this.handleClick();
  },
  mounted() {}
};
</script>
<style scoped>
.el-input {
  width: 35%;
}
</style>
